package com.conjane.algo.array_list;

/**
 * 在数组中查找最大和最小的数值
 */
public class FindLargestSmallestNumberInArray {

    public static void largestAndSmallest(int[] numbers){
        int largest = Integer.MIN_VALUE,smallest = Integer.MAX_VALUE;
        for (int i = 0; i < numbers.length; i++) {
            if (numbers[i] >= largest){
                largest = numbers[i];
            }
            if (numbers[i] <= smallest){
                smallest = numbers[i];
            }
        }
        System.out.println("largest number= " + largest + " smallest number= " + smallest);
    }

    public static void main(String[] args) {
        int[] numbers = new int[]{3,1,3,8090,78,655,42,31343,444};
        largestAndSmallest(numbers);
    }
}
